import requests
class IHRMDEPARTMENT:
    # 封装部门管理接口
    @classmethod
    def department_list(cls,token):
        # 部门列表
        url='http://ihrm2-test.itheima.net/api/company/department'
        headers = {"Authorization": token}
        resp=requests.get(url=url,headers=headers)
        print(resp.json())
        return resp


    @classmethod
    def department_add(cls,token,body):
        # 添加部门
        url='http://ihrm2-test.itheima.net/api/company/department'
        headers={"Content-Type": "application/json", "Authorization": token}
        resp=requests.post(url=url,headers=headers,json=body)
        # print(resp.json())
        return resp

    @classmethod
    def department_query(cls,dep_id,token):
        url='http://ihrm2-test.itheima.net/api/company/department/'+dep_id
        headers={"Authorization": token}
        resp=requests.get(url=url,headers=headers)
        print(resp.json())
        return resp


    @classmethod
    def department_mo(cls,dep_id,token,body):
        # 修改部门
        url='http://ihrm2-test.itheima.net/api/company/department/'+dep_id
        headers={"Content-Type": "application/json", "Authorization": token}
        resp=requests.put(url=url,headers=headers,json=body)
        print(resp.json())
        return resp



    @classmethod
    # 删除部门
    def department_delete(cls,dep_id,token):
        url='http://ihrm2-test.itheima.net/api/company/department/'+dep_id
        headers={"Authorization": token}
        resp=requests.delete(url=url,headers=headers)
        print(resp.json())
        return resp








